#region Using

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;

using Gizmox.WebGUI.Common;
using Gizmox.WebGUI.Forms;

#endregion

namespace TVC.Modules.Com
{
    public partial class frmChangePWD : Form
    {
        public BaseForm MainForm { get; set; }
        public frmChangePWD(BaseForm form)
        {
            InitializeComponent();
            MainForm = form;
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            if (MainForm.PODInfo.PASS == Convert.ToBase64String(new System.Security.Cryptography.SHA1CryptoServiceProvider().ComputeHash(Encoding.ASCII.GetBytes(txtOld.Text))))
            {
                if (txtNew.Text == txtConfirm.Text)
                {
                    MainForm.PODInfo.PASS = Convert.ToBase64String(new System.Security.Cryptography.SHA1CryptoServiceProvider().ComputeHash(Encoding.ASCII.GetBytes(txtNew.Text)));
                    BUS.PODControl ctr = new BUS.PODControl();
                    string sErr = ctr.Update(MainForm.PODInfo);
                    if (sErr == "")
                        lbErr.Text = "Change password successful";
                    else
                        lbErr.Text = "Confirm password is not right!";
                }
                else
                    lbErr.Text = "Confirm password is not right!";
            }
            else
                lbErr.Text = "Old password is not correct!";
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            Close();
        }
    }
}